#include <iostream>
#include <string.h>
using namespace std;
int integrogram[1000][1000];
int ii[1000][1000];
int main()
{
	int x,y;
	cout<<"cin the integrogram's height and width:";
	cin>>x>>y;
	for(int a=0;a<x;a++){
		for(int aa=0;aa<y;aa++) cin>>integrogram[a][aa];
	}
	int i,j;
	memset(ii,0,sizeof(ii));
	for(i=0;i<x;i++){
		int s=integrogram[i][0];
		for(j=0;j<y;j++){
			if(j!=0){
				s=s+integrogram[i][j];
			}
			if(i-1>=0){
				ii[i][j]=ii[i-1][j];
			}
			ii[i][j]+=s;
		}
	}
	for(int k=0;k<x;k++){
		for(int kk=0;kk<y;kk++){
			cout<<ii[k][kk]<<" ";
		}
		cout<<endl;
	}
	return 0;
}
